import os
from types import DynamicClassAttribute

# 按天统计
# 按月统计
# 读取所有的记录数据
lt = []
# 记录按天统计的数据
lltd = []
fm = 'D:\\ping_log_2022.txt'
with open(fm, 'r') as fo:
    cnt = fo.read()
    print(cnt)
    lt = cnt.split('\n')
lt.pop()
tsum = 0
ltb = lt[0].split('\t')
ctd = ltb[0].split(' ')[0]
for item in lt:
    lta = item.split('\t')
    strda = lta[0].split(' ')[0]
    if ctd == strda:
        tsum += int(lta[2])
    else:
        stra = ctd + '\t' + str(tsum)
        lltd.append(stra)
        ctd = strda
        tsum = int(lta[2])
stra = ctd + '\t' + str(tsum)
lltd.append(stra)

print(lltd)
